using System;

namespace SmartBoard.Core.Networking.Client
{
    public class ClientConnectionManager
    {
        public ClientConnectionManager()
        {
            ModuleRegistrationService = new NetworkModuleManager();
            
            DataManager = new ConnectionDataManager
                              {
                                  ModuleManager = ModuleRegistrationService
                              };

            Connection = new ClientNetworkConnection(DataManager.OnDataRecieved);
            DataManager.Connection = Connection;
            ModuleRegistrationService.DataWriter = DataManager as IClientDataWriter;
        }

        private ConnectionDataManager DataManager
        {
            get; set;
        }

        public ClientNetworkConnection Connection
        { 
            get; private set;
        }

        public INetworkModuleManager ModuleRegistrationService
        {
            get; private set;
        }

        internal void Write(byte[] bytes)
        {
            Connection.Write(bytes);
        }
    }
}